package com.deplume.ssm.controller.admin.home;

import com.deplume.ssm.pojo.admin.Delivery;
import com.deplume.ssm.pojo.admin.WorkExp;
import com.deplume.ssm.pojo.common.Result;
import com.deplume.ssm.service.inface.admin.home.IResumeHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by libing on 2016/7/23.
 */
@Controller
@RequestMapping("/resume")
public class ResumeController {

    @Autowired
    IResumeHomeService resumeHomeService;

    @RequestMapping("returnMyResumes")
    public String returnMyResumes(HttpSession session,Model model)throws Exception{
        String user = (String) session.getAttribute("user");
        Delivery delivery = resumeHomeService.selectDeliveryByEmail(user);
        if(delivery != null) {
            List<WorkExp> list = delivery.getResume().getWorkExps();
            System.out.println("================" + delivery.getResume().getCustomer().getFullName());
            model.addAttribute("delivery", delivery);
            model.addAttribute("user", user);
            return "home/myResume";
        }else {
            Result result = new Result();
            result.setMsg("你还未创建简历，点击创建");
            return "home/CreateResume";
        }
    }
    @RequestMapping("returnHome")
    public String returnHomeJsp(HttpSession session,Model model)throws Exception{
        String user = (String) session.getAttribute("user");
        Delivery delivery = resumeHomeService.selectDeliveryByEmail(user);
        if(delivery != null) {
            List<WorkExp> list = delivery.getResume().getWorkExps();
            System.out.println("================" + delivery.getResume().getCustomer().getFullName());
            model.addAttribute("delivery", delivery);
            model.addAttribute("user", user);
            return "home/myResume";
        }else {
            Result result = new Result();
            result.setMsg("你还未创建简历，点击创建");
            return "home/CreateResume";
        }
    }

}
